package com.mall.service.eshop;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mall.client.eshop.EshopUserInfoService;
import com.mall.custom.dao.read.EshopUserInfoReadMapper;
import com.mall.custom.dao.write.EshopUserInfoWriteMapper;
import com.mall.pojo.EshopUserInfo;
import com.mall.pojo.EshopUserInfoExample;
import com.mall.pojo.EshopUserInfoExample.Criteria;
import com.mall.query.Page;
import com.mall.query.eshop.EshopUserQuery;

@Service
public class EshopUserInfoServiceImpl implements EshopUserInfoService {
	// private static final Logger log =
	// LoggerFactory.getLogger(SellerInfoServiceImpl.class);
	@Autowired
	private EshopUserInfoReadMapper EshopUserInfoReadMapper;
	@Autowired
	private EshopUserInfoWriteMapper EshopUserInfoWriteMapper;

	/**
	 * 获得出售店铺人的信息列表
	 * 
	 * @param sellerInfoExample
	 * @return
	 */
	@Override
	public List<EshopUserInfo> getEshopUserInfoListBySellerInfoExample(EshopUserInfoExample sellerInfoExample) {
		// TODO Auto-generated method stub
		return this.EshopUserInfoReadMapper.selectByExample(sellerInfoExample);
	}

	/**
	 * 修改售铺者信息
	 * 
	 * @param sellerInfo
	 * @return
	 */
	@Override
	public int modifyEshopUserInfoBySellerInfo(EshopUserInfo eshopUserInfo) {
		// TODO Auto-generated method stub
		return this.EshopUserInfoWriteMapper.updateByPrimaryKey(eshopUserInfo);
	}

	/**
	 * 添加售铺者信息
	 * 
	 * @param sellerInfo
	 * @return
	 */
	@Override
	public int insertEshopUserInfoBySellerInfo(EshopUserInfo eshopUserInfo) {
		// TODO Auto-generated method stub
		return this.EshopUserInfoWriteMapper.insert(eshopUserInfo);
	}

	/**
	 * 通过id获得售铺者信息
	 * 
	 * @param id
	 * @return
	 */
	@Override
	public EshopUserInfo getEshopUserInfoBySellerInfoId(Long id) {
		// TODO Auto-generated method stub
		return this.EshopUserInfoReadMapper.selectByPrimaryKey(id);
	}

	@Override
	public List<EshopUserInfo> getEshopUserInfoListBySellerInfoByQuery(EshopUserQuery eshopUserQuery, Page page) {
		if (page == null) {
			
		}
		EshopUserInfoExample sellerInfoExample = new EshopUserInfoExample();
		sellerInfoExample.setOrderByClause(eshopUserQuery.getOrderby());
		sellerInfoExample.setLimit(page.getLength());
		sellerInfoExample.setStart(page.getBegin());
		Criteria criteria = sellerInfoExample.createCriteria();
		if (eshopUserQuery.getType() != null) {
			criteria.andTypeEqualTo(eshopUserQuery.getType());
		}
		return this.getEshopUserInfoListBySellerInfoExample(sellerInfoExample);
	}

	@Override
	public Integer getEshopUserInfoCountByExample(EshopUserInfoExample example) {
		return this.EshopUserInfoReadMapper.countByExample(example);
	}

}
